package org.innovasix.educational.javap.domain.constantpool;

import org.innovasix.educational.javap.domain.datatypes.cp_info;
import org.innovasix.educational.javap.domain.datatypes.u1;
import org.innovasix.educational.javap.domain.datatypes.u2;
import org.innovasix.educational.javap.domain.parser.ByteQueue;

/**
 * <p>
 * <b><i>From the JVM specification:</i></b><br/>
 * The CONSTANT_MethodHandle_info structure is used to represent a method handle.
 * </p>
 * 
 * @see <a
 *      href="http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.1">4.4.1.
 *      The CONSTANT_Class_info Structure</a>
 * 
 * @author sven.mentl@gmail.com
 * 
 */
public class CONSTANT_MethodHandle_info extends cp_info {

	public CONSTANT_MethodHandle_info(ByteQueue byteQueue) {
		reference_kind = byteQueue.pollOneByte(CONSTANT_MethodHandle_info.class.getCanonicalName());
		reference_index = byteQueue.pollTwoBytes(CONSTANT_MethodHandle_info.class.getCanonicalName());
	}

	/**
	 * <p>
	 * <b><i>From the JVM specification:</i></b><br/>
	 * The tag item has the value CONSTANT_MethodHandle(15).
	 * </p>
	 */
	final u1 tag = new u1(ConstantPoolTags.CONSTANT_MethodHandle.decimalValue());

	/**
	 * <p>
	 * <b><i>From the JVM specification:</i></b><br/>
	 * The value of the reference_kind item must
	 * be in the range 1 to 9. The value denotes the kind of this method handle,
	 * which characterizes its bytecode behavior.
	 */
	u1 reference_kind;
	
	/**
	 * <p>
	 * <b><i>From the JVM specification:</i></b><br/>
	 * The value of the reference_index must be a valid index into the
	 * constant_pool table.
	 */
	u2 reference_index;

}
